
package com.barnabe;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

/* @author Arthur F. Zanona */

public class ClienteMiddleware {
    private Socket s;
    private String host;
    private Integer port;

    public ClienteMiddleware(String host, Integer port) {
        this.host = host;
        this.port = port;
    }



    public void abrirComunicacao() throws UnknownHostException, IOException {
        if ( s == null ) s = new Socket(host, port);
    }

    public void fecharComunicacao() throws IOException{
        if ( s != null ) {
            s.close();
        }
    }

    public boolean isConectado(){
        return s == null ? false : s.isConnected() ;
    }

}
